// mine/pages/signinlists/index.js
const $api = require("../../../api/mine").API

Page({

  /**
   * 页面的初始数据
   */
  data: {
    sign_year:new Date().getFullYear(),
    sign_month:new Date().getMonth(),
    currentDate: new Date().getTime(),
    minDate: new Date().getTime(),
    showchoosetime:false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var t = this
  },
  onReady:function(){
    var t = this
    t.getTeacherAttendance()
  },
  getTeacherAttendance(){
    var t= this,
    data = {
      item_id:wx.getStorageSync('memberinfo').member_id,
      sign_year:t.data.sign_year,
      sign_month:t.data.sign_month,
    }
    $api.getTeacherAttendance(data).then(res=>{
      console.log(res)
      t.setData({
        lists:res.data.records
      })
    })
  },
  onClose(){
    var t= this
    t.setData({
      showchoosetime:false
    })
  },
  choosetime(){
    var t= this
    t.setData({
      showchoosetime:true
    })
  },
  choosed(e){
    var t = this
    t.setData({
      showchoosetime:false
    })
    console.log("选择时间确定choosed")
    t.getTeacherAttendance()

  },
  timechange(e){
    var t= this
    console.log(e)
    var time = e.detail
    if (time) {
      var oDate = new Date(time * 1),
        oYear = oDate.getFullYear(),
        oMonth = oDate.getMonth() + 1
        t.setData({
          sign_year:oYear,
          sign_month:oMonth,
          currentDate:time
        })
    }
  },
})